 #define _CRT_SECURE_NO_WARNINGS 1

class MaxGap {
public:
    int findMaxGap(vector<int> A, int n) {
        int Max = 0;
        for (auto e : A)
            Max = max(Max, e);

        int Min = min(A[0], A[n - 1]);

        return Max - Min;
    }
};

#include <iostream>
#include <vector>
#include <climits>
using namespace std;

class Printer {
public:
    vector<int> clockwisePrint(vector<vector<int> > mat, int n, int m) {
        vector<int> ret;
        int order[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };

        int i = 0, j = -1, start = 0;
        while (true)
        {
            int x = i + order[start][0], y = j + order[start][1];
            if (x > n - 1 || x < 0 || y > m - 1 || y < 0 || mat[x][y] == INT_MAX)
                start = (start + 1) % 4;

            i += order[start][0], j += order[start][1];

            ret.push_back(mat[i][j]);
            mat[i][j] = INT_MAX;

            if (ret.size() == m * n)
                break;
        }

        return ret;
    }
};